Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/aws: Check credentials before attempting to do anything #2730

Merged
merged 1 commit into from
Jul 21, 2015

Conversation

catsby
Copy link
Contributor

@catsby catsby commented Jul 14, 2015

Attempt to get the current user through IAM, in effort to verify the credentials work at all prior to doing anything.

Before:

$ AWS_SECRET_ACCESS_KEY=nope terraform plan
[...]

+ aws_instance.tf_test
    ami:                         "" => "ami-6ff2f15f"
  [....] # a bunch of planned things

$ AWS_SECRET_ACCESS_KEY=nope terraform apply
aws_key_pair.ssh_thing: Creating...
  [...]
aws_key_pair.ssh_thing: Error: 1 error(s) occurred:

* Error import KeyPair: AuthFailure: AWS was not able to validate the provided access credentials
    status code: 401, request id: []
aws_vpc.default: Error: 1 error(s) occurred:

* Error creating VPC: AuthFailure: AWS was not able to validate the provided access credentials
    status code: 401, request id: []
Error applying plan:

3 error(s) occurred:

* Error import KeyPair: AuthFailure: AWS was not able to validate the provided access credentials
    status code: 401, request id: []
* Error creating VPC: AuthFailure: AWS was not able to validate the provided access credentials
    status code: 401, request id: []
* Resource 'aws_internet_gateway.gw' does not have attribute 'id' for variable 'aws_internet_gateway.gw.id'

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

After:

$ AWS_SECRET_ACCESS_KEY=nope terraform plan
Refreshing Terraform state prior to plan...

Error refreshing state: 1 error(s) occurred:

* 1 error(s) occurred:

* Failed authenticating with AWS: please verify credentials

Note that the bad credentials are caught at the plan stage.

Fixes #2703

@phinze
Copy link
Contributor

phinze commented Jul 14, 2015

Ooo this is a great idea. 👍

@radeksimko
Copy link
Member

👍

@catsby
Copy link
Contributor Author

catsby commented Jul 14, 2015

heh, idea credit to @gtmtech 😄

catsby added a commit that referenced this pull request Jul 21, 2015
provider/aws: Check credentials before attempting to do anything
@catsby catsby merged commit 70cf3a7 into master Jul 21, 2015
@catsby catsby deleted the f-aws-fail-nicer branch July 21, 2015 13:34
mitto added a commit to mitto/homebrew that referenced this pull request Aug 8, 2015
Fixed test for the credentials check is enhanced when you run from version 0.6.2 'terraform plan'.
Ref: hashicorp/terraform#2730
mitto added a commit to mitto/homebrew that referenced this pull request Aug 8, 2015
dunn pushed a commit to Homebrew/legacy-homebrew that referenced this pull request Aug 8, 2015
Fix functionally test use 'terraform graph' instead of 'terraform plan'

Depends: hashicorp/terraform#2730

Closes #42613.

Signed-off-by: Alex Dunn <dunn.alex@gmail.com>
@ghost
Copy link

ghost commented May 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terraform crash on invalid AWS keys
3 participants